package protocol.funccode;

import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import protocol.Command;
import protocol.CommandException;
import protocol.FrameGenerator;
import protocol.funccode.registers.RegTblParserException;
import core.ProcessThread;


/*
 * Created on 2004-8-12
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */

/**
 * @author pdv
 *
 * ���ڹ������Command������·��Ŀר��
 * ��������
 * ֡ͷ					stx��1 byte��
 * ������			����·��Ŀ	8 byte			FuncCode
 * �豸��Ż���
 * ������		����·��Ŀ	15 byte			DevID/RegionID
 * ʱ��						14 byte			TimeID
 * �ӹ�����					2 byte			SubFuncCode
 * ����Ψһ��ʶ				36 byte			CUID(GUID)
 * ��ݶ�����					x byte			Data
 * ֡β					etx��1 byte��
 */
public class FcCommand extends Command {
    public final static int FUNC_CODE_LEN = 8;
    public final static int ID_LEN = 15;
    public final static int TIME_LEN = 14;
    public final static int SUBCODE_LEN = 2;
    public final static int UID_LEN = 36;
	private int versionNo;
	private String sFuncCode;
    private long iFuncCode;
    //id��ʶ���豸id������id
    private boolean hasID = false;
	private String id;
	private void setID() {
	    hasID = true;
	}
	//ʱ���ʶ
	private boolean hasTimeID = false;
	private String timeID;
	private Date time;
	private void setTimeID() {
	    hasTimeID = true;
	}
	//�����ʶ
	private boolean hasSubCode = false;
	private String sSubCode;
	private int iSubCode;
	private void setSubCode() {
	    hasSubCode = true;
	}
	//unique id��ʶ
	private boolean hasUID = false;
	public boolean isHasUID() {
		return hasUID;
	}
	private String uID;
	private void setUID() {
	    hasUID = true;
	}
	//ʣ���Ϊ��ݶ�
	private String data;
	private boolean isDown;
	private String rawstr;

	private String getStringPart(StringBuffer buf, int len) {
	    String res = buf.substring(0, len);
	    buf.delete(0, len);
	    return res;
	}
	/**
	 * 
	 * @param s frame
	 * @throws FcCommandException
	 */
	public FcCommand(String s)
		throws FcCommandException {
		super();
		rawstr = s;
	    StringBuffer buf = new StringBuffer(s);
	    try {
	    	versionNo = Integer.parseInt(s.substring(1, 3), 16);
	    } catch (IndexOutOfBoundsException e) {
	        throw new FcCommandException("frame too short:"+s);
	    }
	    try {
            this.sFuncCode = getStringPart(buf, FUNC_CODE_LEN);
            if (sFuncCode.charAt(0)=='8' || sFuncCode.charAt(0)=='2')
		        isDown = false;
		    else if (sFuncCode.charAt(0)=='9' || sFuncCode.charAt(0)=='3')
		        isDown = true;
		    else if (!this.sFuncCode.equalsIgnoreCase("FFFFFFFF"))
		        throw new FcCommandException("invalid func code:"+s);
            this.iFuncCode = Long.parseLong(sFuncCode, 16);
            initCommand(iFuncCode);
        } catch (NumberFormatException e) {
            throw new FcCommandException("invalid func code:"+s);
        } catch (IndexOutOfBoundsException e) {
            throw new FcCommandException("frame too short:"+s);
        }
	    if (this.hasID) {
	        try {
	            this.id = getStringPart(buf, ID_LEN);
	        } catch (IndexOutOfBoundsException e) {
	            throw new FcCommandException("frame too short:"+s);
	        }
	    }
        if (this.hasTimeID) {
            try {
                String time = getStringPart(buf, TIME_LEN);
                SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
                formatter.setLenient(false);
                this.time = formatter.parse(time);
                this.timeID = time;
            } catch (IndexOutOfBoundsException e) {
	            throw new FcCommandException("frame too short:"+s);
	        } catch (ParseException e) {
	            throw new FcCommandException("timeID error:"+s);
            }
        }
        if (this.hasSubCode) {
            try {
                this.sSubCode = getStringPart(buf, SUBCODE_LEN);
                this.iSubCode = Integer.parseInt(sSubCode, 16);
            } catch (NumberFormatException e) {
                throw new FcCommandException("invalid sub code:"+s);
            } catch (IndexOutOfBoundsException e) {
                throw new FcCommandException("frame too short:"+s);
            }
        }
        if (this.hasUID) {
            try {
                this.uID = getStringPart(buf, UID_LEN);
            } catch (IndexOutOfBoundsException e) {
                throw new FcCommandException("frame too short:"+s);
            }
        }
        this.data = buf.toString();
	}
	//YA��ѯ
	public static final String YA_MDT_POLL_STR = "20011100";
	public static final long YA_MDT_POLL = Long.parseLong(YA_MDT_POLL_STR, 16);
	public static final String YA_RODT_POLL_STR = "20011300"; 
	public static final long YA_RODT_POLL = Long.parseLong(YA_RODT_POLL_STR, 16);
	public static final String YA_IB_POLL_STR = "20012000";
	public static final long YA_IB_POLL = Long.parseLong(YA_IB_POLL_STR, 16);
	public static final String YA_LPI_POLL_STR = "20014100";
	public static final long YA_LPI_POLL = Long.parseLong(YA_LPI_POLL_STR, 16);
	public static final String YA_RC_POLL_LCB_STR = "20013200";
	public static final long YA_RC_POLL_LCB = Long.parseLong(YA_RC_POLL_LCB_STR, 16);
	
	//YA��ʷ��ݻָ��ϴ�
	public static final String YA_MDT_RESTORE_DATA_POLL_STR = "20031100";
	public static final long YA_MDT_RESTORE_DATA_POLL = Long.parseLong(YA_MDT_RESTORE_DATA_POLL_STR, 16);
	public static final String YA_RODT_RESTORE_DATA_POLL_STR = "20031300";
	public static final long YA_RODT_RESTORE_DATA_POLL = Long.parseLong(YA_RODT_RESTORE_DATA_POLL_STR, 16);
	
	//YA�յ������·�
	public static final String YA_AB_CMD_TEXT_STR = "30052100";
	public static final long YA_AB_CMD_TEXT = Long.parseLong(YA_AB_CMD_TEXT_STR, 16);
	public static final String YA_MB_CMD_TEXT_STR = "30052300";
	public static final long YA_MB_CMD_TEXT = Long.parseLong(YA_MB_CMD_TEXT_STR, 16);
	public static final String YA_LB_CMD_LB_STR = "30052200";
	public static final long YA_LB_CMD_LB = Long.parseLong(YA_LB_CMD_LB_STR, 16);
	public static final String YA_MB_CMD_LB_STR = "30052301";
	public static final long YA_MB_CMD_LB = Long.parseLong(YA_MB_CMD_LB_STR, 16);
	public static final String YA_RC_CMD_LCB_STR = "30053200";
	public static final long YA_RC_CMD_LCB= Long.parseLong(YA_RC_CMD_LCB_STR, 16);
	//YA�յ������ִ	
	public static final String YA_AB_RESPONSE_TEXT_STR = "20052100";
	public static final long YA_AB_RESPONSE_TEXT = Long.parseLong(YA_AB_RESPONSE_TEXT_STR, 16);
	public static final String YA_MB_RESPONSE_TEXT_STR = "20052300";
	public static final long YA_MB_RESPONSE_TEXT = Long.parseLong(YA_MB_RESPONSE_TEXT_STR, 16);
	public static final String YA_MB_RESPONSE_LB_STR = "20052301";
	public static final long YA_MB_RESPONSE_LB = Long.parseLong(YA_MB_RESPONSE_LB_STR, 16);
	public static final String YA_LB_RESPONSE_LB_STR = "20052200";
	public static final long YA_LB_RESPONSE_LB = Long.parseLong(YA_LB_RESPONSE_LB_STR, 16);
	public static final String YA_RC_RESPONSE_LCB_STR ="20053200";
	public static final long YA_RC_RESPONSE_LCB = Long.parseLong(YA_RC_RESPONSE_LCB_STR,16);
	//YA��ʷ��ݻָ��·�
	public static final String YA_MDT_RESTORE_DATA_CMD_STR = "30031100";
	public static final long YA_MDT_RESTORE_DATA_CMD = Long.parseLong(YA_MDT_RESTORE_DATA_CMD_STR, 16);
	public static final String YA_RODT_RESTORE_DATA_CMD_STR = "30031300";
	public static final long YA_RODT_RESTORE_DATA_CMD = Long.parseLong(YA_RODT_RESTORE_DATA_CMD_STR, 16);
	
	//��ѯ
	public static final String VDT_POLL_STR = "80011000";
	public static final long VDT_POLL = Long.parseLong(VDT_POLL_STR, 16);
	public static final String RC_POLL_STR = "80013000";
	public static final long RC_POLL = Long.parseLong(RC_POLL_STR, 16);
	
	public static final String IB_POLL_STR = "80012000";
	public static final long IB_POLL = Long.parseLong(IB_POLL_STR, 16);
	
	public static final String IB_POLL_DEVSTATESTR = "80012001";
	public static final long IB_POLL_DEVSTATE = Long.parseLong(IB_POLL_DEVSTATESTR, 16);
	
	
	public static final String SB_POLL_STR = "80012400";
	public static final long SB_POLL = Long.parseLong(SB_POLL_STR, 16);
	public static final String SQVDT_POLL_STR = "80011700";
	public static final long SQVDT_POLL = Long.parseLong(SQVDT_POLL_STR, 16);
	public static final String NORVDT_POLL_STR = "80011900";
	public static final long NORVDT_POLL = Long.parseLong(NORVDT_POLL_STR, 16);
	
	public static final String RD_POLL_STR = "80011800";
	public static final long RD_POLL = Long.parseLong(RD_POLL_STR, 16);

	public static final String RD_POLL_FILE_STR = "80011801";
	public static final long RD_POLL_FILE = Long.parseLong(RD_POLL_FILE_STR, 16);

	public static final String RD_RESTORE_DATA_POLL_STR = "80031800";
	public static final long RD_RESTORE_DATA_POLL = Long.parseLong(RD_RESTORE_DATA_POLL_STR, 16);
	public static final String RD_HIST_RESTORE_REQ_STR = "90031800";
	public static final String RD_BOOT_EVENT_STR = "80081800";
	public static final long RD_BOOT_EVENT = Long.parseLong(RD_BOOT_EVENT_STR, 16);
	public static final String RD_SHUTDOWN_EVENT_STR ="80081801";
	public static final long RD_SHUTDOWN_EVENT = Long.parseLong(RD_SHUTDOWN_EVENT_STR, 16);
	public static final String RD_VEHICLE_IN_STR = "80081802";
	public static final long RD_VEHICLE_IN = Long.parseLong(RD_VEHICLE_IN_STR, 16);
	public static final String RD_VEHICLE_CANCELIN_STR = "80081803";
	public static final long RD_VEHICLE_CANCELIN = Long.parseLong(RD_VEHICLE_CANCELIN_STR, 16);
	public static final String RD_VEHICLE_OUT_STR = "80081804";
	public static final long RD_VEHICLE_OUT = Long.parseLong(RD_VEHICLE_OUT_STR, 16);
	public static final String RD_SENSOR_STATE_STR = "80081805";
	public static final long RD_SENSOR_STATE = Long.parseLong(RD_SENSOR_STATE_STR, 16);
	public static final String RD_TRAFFIC_STATE_STR = "80011806";
	public static final long RD_TRAFFIC_STATE = Long.parseLong(RD_TRAFFIC_STATE_STR, 16);
	public static final String RD_START_SEND_VEHINFO_STR = "90021800";
	public static final String RD_STOP_SEND_VEHINFO_STR = "90021801";
	public static final String RD_START_SEND_TRAFINFO_STR = "90021802";
	public static final String RD_STOP_SEND_TRAFINFO_STR = "90021803";
	public static final String RD_MODIFY_INTERVAL_STR = "90021804";
	public static final String RD_MODIFY_SENSOR_TO_COLLECT_STR = "90021805";
	public static final String RD_DAILY_DATA_STAT_STR = "90021808";
	public static final String RD_DAILY_DATA_STAT_RESPONSE_STR = "80021808";
	public static final long RD_DAILY_DATA_STAT_RESPONSE = Long.parseLong(RD_DAILY_DATA_STAT_RESPONSE_STR, 16); 
	public static final String RD_INTERVAL_REQUEST_STR = "90041800";
	public static final String RD_DEV_WORKSTATE_REQUEST_STR = "90041801";
	public static final String RD_SENSOR_WORKSTATE_REQUEST_STR = "90041802";
	public static final String RD_INTERVAL_RESPONSE_STR = "80041800";
	public static final long RD_INTERVAL_RESPONSE = Long.parseLong(RD_INTERVAL_RESPONSE_STR, 16);
	public static final String RD_DEV_WORKSTATE_RESPONSE_STR = "80041801";
	public static final long RD_DEV_WORKSTATE_RESPONSE = Long.parseLong(RD_DEV_WORKSTATE_RESPONSE_STR, 16);
	public static final String RD_SENSOR_WORKSTATE_RESPONSE_STR = "80041802";
	public static final long RD_SENSOR_WORKSTATE_RESPONSE = Long.parseLong(RD_SENSOR_WORKSTATE_RESPONSE_STR, 16);

	
	
	//���յ�ʵʱ�����ѯ
	public static final String AIRLIGHTCONTROLLER_POLL_STR = "80014A00";
	public static final long AIRLIGHTCONTROLLER_POLL = Long.parseLong(AIRLIGHTCONTROLLER_POLL_STR, 16);
	
	
	//AUTOSCOPE
	public static final String AUTOSCOPEVDT_POLL_STR = "80011500";
	public static final long AUTOSCOPEVDT_POLL = Long.parseLong(AUTOSCOPEVDT_POLL_STR,16);
	public static final String AUTOSCOPEVDT_EVENT_STR = "80081500";
	public static final long AUTOSCOPEVDT_EVENT = Long.parseLong(AUTOSCOPEVDT_EVENT_STR,16);
	
	
	//���س�ʪ��ʵʱ�����ѯ
	public static final String MUNTERSDH_POLL_STR = "80014500";
	public static final long MUNTERSDH_POLL = Long.parseLong(MUNTERSDH_POLL_STR, 16);
	
	//EIS΢��������ʵʩ�����ѯ
	public static final String EISMWVDT_POLL_STR = "80011A00";
	public static final long EISMWVDT_POLL = Long.parseLong(EISMWVDT_POLL_STR, 16);
	
	//����������ʵʱ��ѯ
	public static final String SEARICP_POLL_STR = "80014200";
	public static final long SEARICP_POLL = Long.parseLong(SEARICP_POLL_STR, 16);	
	
	//��������ŵ�����������ѯ
	public static final String EP_POLL_STR = "80019000";
	public static final long EP_POLL = Long.parseLong(EP_POLL_STR, 16);	
	
	//��������ų��������ѯ
	public static final String WEIGH_POLL_STR = "80019B00";
	public static final long WEIGH_POLL = Long.parseLong(WEIGH_POLL_STR, 16);	
	
	
	//superconn������
	public static final String SUPCONVDT_RESTORE_DATA_CMD_STR = "90038000";
	public static final long SUPCONVDT_RESTORE_DATA_CMD = Long.parseLong(SUPCONVDT_RESTORE_DATA_CMD_STR, 16);
	public static final String SUPCONVDT_RESTORE_DATA_POLL_STR = "80038000";
	public static final long SUPCONVDT_RESTORE_DATA_POLL = Long.parseLong(SUPCONVDT_RESTORE_DATA_POLL_STR, 16);
	
	
	//ROSA����վʵʱ�����ѯ
	public static final String WSROSA_POLL_STR = "80015000";
	public static long WSROSA_POLL = Long.parseLong(WSROSA_POLL_STR,16);
	//FD12�ܼ��ʵʱ�����ѯ
	public static final String VMFD12_POLL_STR = "80015100";
	public static long VMFD12_POLL = Long.parseLong(VMFD12_POLL_STR,16);
	
	//�������������ʶ��
	public static final String SEARIYFCP_POLL_STR = "80014300";
	public static long SEARIYFCP_POLL = Long.parseLong(SEARIYFCP_POLL_STR,16);
	
	public static final String SEARIYFCP_POLL_CP_STR = "80014301";
	public static long SEARIYFCP_POLL_CP = Long.parseLong(SEARIYFCP_POLL_CP_STR,16);
	
	//�������ϵͳ������������ʵʱ�ϴ�
	public static final String SEARIYFENVDEV_POLL_STR = "80019C00";
	public static long SEARIYFENVDEV_POLL = Long.parseLong(SEARIYFENVDEV_POLL_STR,16);
	
	//COWIN���ر�����Ϣ�ϴ�
	public static final String JFJK_COWIN_EVENT_STR = "80085A00";
	public static long JFJK_COWIN_EVENT = Long.parseLong(JFJK_COWIN_EVENT_STR,16);
	
	//��ɽ���ź��յ�����ϴ�

	public static final String JXJ_TBCTRL_POLL_STR = "80014B00";
	public static long JXJ_TBCTRL_POLL = Long.parseLong(JXJ_TBCTRL_POLL_STR,16);
	
	//��ɽ��������ϴ�
	public static final String ZSEP_POLL_STR = "80019D00";
	public static long ZSEP_POLL = Long.parseLong(ZSEP_POLL_STR,16);
	
	//��ɽPLC����ϴ�
	public static final String ZSPLC_POLL_STR = "80019E00";
	public static long ZSPLC_POLL = Long.parseLong(ZSPLC_POLL_STR,16);
	
	//������������ϴ�
	public static final String NOHMIBMS_POLL_STR = "80086000";
	public static long NOHMIBMS_POLL = Long.parseLong(NOHMIBMS_POLL_STR,16);

	//�ѵ���ͨ�������·�
	public static final String RC_TRAFFICSIGNAL_CMD_STR = "90053008";
	public static final long RC_TRAFFICSIGNAL_CMD = Long.parseLong(RC_TRAFFICSIGNAL_CMD_STR, 16);
	
	//�ѵ���ͨ��ʵʱ�����ѯ
	public static final String RC_TRAFFICSIGNAL_POLL_STR = "80013002";
	public static final long RC_TRAFFICSIGNAL_POLL = Long.parseLong(RC_TRAFFICSIGNAL_POLL_STR, 16);
	
//EXPRC WHOLE POLL-----------------------------------------------------------------------------------------	
	//EXPRC POLL
	public static final String EXPRC_POLL_STR = "80013300";
	public static final long EXPRC_POLL = Long.parseLong(EXPRC_POLL_STR, 16);

	//EXPRC RPLGROUP POLL
	public static final String EXPRC_RPLGROUP_POLL_STR = "80013301";
	public static final long EXPRC_RPLGROUP_POLL = Long.parseLong(EXPRC_RPLGROUP_POLL_STR, 16);

	//EXPRC RCVDT POLL
	public static final String EXPRC_RCVDT_POLL_STR = "80013302";
	public static final long EXPRC_RCVDT_POLL = Long.parseLong(EXPRC_RCVDT_POLL_STR, 16);
	
	//EXPRC RCVDT HIST
	public static final String EXPRC_RCVDT_HISTDATA_STR = "80033300";
	public static final long EXPRC_RCVDT_HISTDATA = Long.parseLong(EXPRC_RCVDT_HISTDATA_STR, 16);

	
	//EXPRC RTB POLL
	public static final String EXPRC_RTB_POLL_STR = "80013303";
	public static final long EXPRC_RTB_POLL = Long.parseLong(EXPRC_RTB_POLL_STR, 16);

	//EXPRC RTB STATE POLL
	public static final String EXPRC_RTB_STATE_POLL_STR = "80013304";
	public static final long EXPRC_RTB_STATE_POLL = Long.parseLong(EXPRC_RTB_STATE_POLL_STR, 16);

	
	//EXPRC RCIB POLL
	public static final String EXPRC_RCIB_POLL_STR = "80013305";
	public static final long EXPRC_RCIB_POLL = Long.parseLong(EXPRC_RCIB_POLL_STR, 16);
	
	//EXPRC RCIB STATE POLL
	public static final String EXPRC_RCIB_STATE_POLL_STR = "80013306";
	public static final long EXPRC_RCIB_STATE_POLL = Long.parseLong(EXPRC_RCIB_STATE_POLL_STR, 16);

	//EXPRC SIGNAL POLL
	public static final String EXPRC_SIGNAL_POLL_STR = "80013307";
	public static final long EXPRC_SIGNAL_POLL = Long.parseLong(EXPRC_SIGNAL_POLL_STR, 16);
	
	


	
	//��������
	public static final String AIRLIGHTCONTROLLER_DNTHRESHOLD_SET_STR = "90024A00";
	public static final long AIRLIGHTCONTROLLER_DNTHRESHOLD_SET = Long.parseLong(AIRLIGHTCONTROLLER_DNTHRESHOLD_SET_STR, 16);
	
	//�������÷���
	public static final String AIRLIGHTCONTROLLER_DNTHRESHOLD_SET_RESPONSE_STR = "80024A00";
	public static final long AIRLIGHTCONTROLLER_DNTHRESHOLD_SET_RESPONSE = Long.parseLong(AIRLIGHTCONTROLLER_DNTHRESHOLD_SET_RESPONSE_STR, 16);

	
	
	//�����ѯ
	public static final String AIRLIGHTCONTROLLER_DNTHRESHOLD_QUERY_STR = "90044A00";
	public static final long AIRLIGHT_DNTHRESHOLD_QUERY = Long.parseLong(AIRLIGHTCONTROLLER_DNTHRESHOLD_QUERY_STR, 16);

	//�����ѯ��ִ
	public static final String AIRLIGHTCONTROLLER_DNTHRESHOLD_QUERY_RESPONSE_STR = "80044A00";
	public static final long AIRLIGHTCONTROLLER_DNTHRESHOLD_QUERY_RESPONSE = Long.parseLong(AIRLIGHTCONTROLLER_DNTHRESHOLD_QUERY_RESPONSE_STR, 16);
	

	/*���ѵ�Э��-------------------------------------------------------------------------------------------------*/
	//�ѵ�����ѯ����(ֻ��LED��ʵʱ��ݲ�ѯ)
	public static final String RCIB_POLL_STR = "80013001";
	public static final long RCIB_POLL = Long.parseLong(RCIB_POLL_STR, 16);
	
	//�ѵ����ְ巢���յ���Ϣ����IB_CMD_TEXT_STR
	public static final String RC_IB_CMD_TEXT_CONTROL_STR = "90053002";
	public static final long RC_IB_CMD_TEXT_CONTROL = Long.parseLong(RC_IB_CMD_TEXT_CONTROL_STR, 16);

	public static final String RC_IB_CMD_LB_CONTROL_STR = "90053003";
	public static final long RC_IB_CMD_LB_CONTROL = Long.parseLong(RC_IB_CMD_LB_CONTROL_STR, 16);

	public static final String RC_IB_CMD_STATIC_CONTROL_STR = "90053004";
	public static final long RC_IB_CMD_STATIC_CONTROL = Long.parseLong(RC_IB_CMD_STATIC_CONTROL_STR, 16);
	
	//�·�����
	public static final String RC_IB_RESPONSE_TEXT_STR = "80053002";
	public static final long RC_IB_RESPONSE_TEXT = Long.parseLong(RC_IB_RESPONSE_TEXT_STR, 16);

	public static final String RC_IB_RESPONSE_LB_STR = "80053003";
	public static final long RC_IB_RESPONSE_LB = Long.parseLong(RC_IB_RESPONSE_LB_STR, 16);
	
	public static final String RC_IB_RESPONSE_STATIC_STR = "80053004";
	public static final long RC_IB_RESPONSE_STATIC = Long.parseLong(RC_IB_RESPONSE_STATIC_STR, 16);
	
	public static final String RC_TRAFFICSIGNAL_RESPONSE_STR = "80053005";
	public static final long RC_TRAFFICSIGNAL_RESPONSE = Long.parseLong(RC_TRAFFICSIGNAL_RESPONSE_STR, 16);


	
	
	//�ѵ���ͨ�������
	public static final String RC_RESPONSE_TRAFFICSIGNAL_CMD_STR = "80053008";
	public static final long RC_RESPONSE_TRAFFICSIGNAL_CMD = Long.parseLong(RC_RESPONSE_TRAFFICSIGNAL_CMD_STR, 16);

	
	//����������·�
	public static final String ENVDEV_IOOUTPUT_CMD_STR = "90059C00";
	public static final long ENVDEV_IOOUTPUT_CMD = Long.parseLong(ENVDEV_IOOUTPUT_CMD_STR, 16);
	
	public static final String ENVDEV_RESPONSE_IOOUTPUT_STR = "80059C00";
	public static final long ENVDEV_RESPONSE_IOOUTPUT = Long.parseLong(ENVDEV_RESPONSE_IOOUTPUT_STR, 16);
	
	//�������������
	public static final String ENVDEV_SHAKEALARM_RESEST_CMD_STR = "90059C01";
	public static final long ENVDEV_SHAKEALARM_RESEST_CMD = Long.parseLong(ENVDEV_SHAKEALARM_RESEST_CMD_STR, 16);
	
	public static final String ENVDEV_RESPONSE_SHAKEALARM_RESEST_STR = "80059C01";
	public static final long ENVDEV_RESPONSE_SHAKEALARM_RESEST = Long.parseLong(ENVDEV_RESPONSE_SHAKEALARM_RESEST_STR, 16);

	//С½������Ŀ
	
	//�·�
	public static final String XLJZ_AMS_TEXT_CMD_STR = "90052600";
	public static final String XLJZ_FMS_TEXT_CMD_STR = "90052601";
	public static final String XLJZ_FMS_LB_CMD_STR = "90052602";
	public static final String XLJZ_FMS_STATIC_CMD_STR = "90052603";
	public static final String XLJZ_SMS_STATIC_CMD_STR = "90052604";
	public static final String XLJZ_AMS_STATIC_CMD_STR = "90052608";
	public static final String XLJZ_AMS_LB_CMD_STR = "90052607";
	public static final String XLJZ_MS_PARAMSET_STR = "90022601";
	public static final String XLJZ_MS_PARAMQUERY_STR = "90042602";
	
	//�·�����
	public static final String XLJZ_AMS_TEXT_CMD_RESPONSE_STR = "80052600";
	public static final long XLJZ_AMS_TEXT_CMD_RESPONSE = Long.parseLong(XLJZ_AMS_TEXT_CMD_RESPONSE_STR, 16);

	public static final String XLJZ_FMS_TEXT_CMD_RESPONSE_STR = "80052601";
	public static final long XLJZ_FMS_TEXT_CMD_RESPONSE = Long.parseLong(XLJZ_FMS_TEXT_CMD_RESPONSE_STR, 16);
	
	public static final String XLJZ_FMS_LB_CMD_RESPONSE_STR = "80052602";
	public static final long XLJZ_FMS_LB_CMD_RESPONSE = Long.parseLong(XLJZ_FMS_LB_CMD_RESPONSE_STR, 16);
	
	public static final String XLJZ_FMS_STATIC_CMD_RESPONSE_STR = "80052603";
	public static final long XLJZ_FMS_STATIC_CMD_RESPONSE = Long.parseLong(XLJZ_FMS_STATIC_CMD_RESPONSE_STR, 16);
	
	public static final String XLJZ_SMS_STATIC_CMD_RESPONSE_STR = "80052604";
	public static final long XLJZ_SMS_STATIC_CMD_RESPONSE = Long.parseLong(XLJZ_SMS_STATIC_CMD_RESPONSE_STR, 16);

	public static final String XLJZ_AMS_LB_CMD_RESPONSE_STR = "80052607";
	public static final long XLJZ_AMS_LB_CMD_RESPONSE = Long.parseLong(XLJZ_AMS_LB_CMD_RESPONSE_STR, 16);
	
	public static final String XLJZ_AMS_STATIC_CMD_RESPONSE_STR = "80052608";
	public static final long XLJZ_AMS_STATIC_CMD_RESPONSE = Long.parseLong(XLJZ_AMS_STATIC_CMD_RESPONSE_STR, 16);
	
	public static final String XLJZ_MS_PARAMSET_RESPONSE_STR = "80022600";
	public static final long XLJZ_MS_PARAMSET_RESPONSE = Long.parseLong(XLJZ_MS_PARAMSET_RESPONSE_STR, 16);

	public static final String XLJZ_MS_PARAMQUERY_RESPONSE_STR = "90042602";
	public static final long XLJZ_MS_PARAMQUERY_RESPONSE = Long.parseLong(XLJZ_MS_PARAMQUERY_RESPONSE_STR, 16);

	
	//��ѯ
	public static final String XLJZ_AMS_POLL_STR = "80012600";
	public static final long XLJZ_AMS_POLL = Long.parseLong(XLJZ_AMS_POLL_STR, 16);
	public static final String XLJZ_FMS_POLL_STR = "80012601";
	public static final long XLJZ_FMS_POLL = Long.parseLong(XLJZ_FMS_POLL_STR, 16);
	public static final String XLJZ_SMS_POLL_STR = "80012602";
	public static final long XLJZ_SMS_POLL = Long.parseLong(XLJZ_SMS_POLL_STR, 16);
	public static final String XLJZ_AMS_DEVSTATE_POLL_STR = "80012603";
	public static final long XLJZ_AMS_DEVSTATE_POLL = Long.parseLong(XLJZ_AMS_DEVSTATE_POLL_STR, 16);
	public static final String XLJZ_FMS_DEVSTATE_POLL_STR = "80012604";
	public static final long XLJZ_FMS_DEVSTATE_POLL = Long.parseLong(XLJZ_FMS_DEVSTATE_POLL_STR, 16);
	public static final String XLJZ_SMS_DEVSTATE_POLL_STR = "80012605";
	public static final long XLJZ_SMS_DEVSTATE_POLL = Long.parseLong(XLJZ_SMS_DEVSTATE_POLL_STR, 16);
	
    //�ļ��ϴ�
	public static final String XLJZ_AMS_UPLOAD_STR = "90052605";
	public static final long XLJZ_AMS_UPLOAD = Long.parseLong(XLJZ_AMS_UPLOAD_STR, 16);
	
	public static final String XLJZ_AMS_UPLOAD_RESPONSE_STR = "80052605";
	public static final long XLJZ_AMS_UPLOAD_RESPONSE = Long.parseLong(XLJZ_AMS_UPLOAD_RESPONSE_STR, 16);

	public static final String XLJZ_FMS_UPLOAD_STR = "90052606";
	public static final long XLJZ_FMS_UPLOAD = Long.parseLong(XLJZ_FMS_UPLOAD_STR, 16);
	
	public static final String XLJZ_FMS_UPLOAD_RESPONSE_STR = "80052606";
	public static final long XLJZ_FMS_UPLOAD_RESPONSE = Long.parseLong(XLJZ_FMS_UPLOAD_RESPONSE_STR, 16);
	
	//�ļ�����
	public static final String XLJZ_AMS_DNLOAD_STR = "90042600";
	public static final long XLJZ_AMS_DNLOAD = Long.parseLong(XLJZ_AMS_DNLOAD_STR, 16);
	
	public static final String XLJZ_AMS_DNLOAD_RESPONSE_STR = "80042600";
	public static final long XLJZ_AMS_DNLOAD_RESPONSE = Long.parseLong(XLJZ_AMS_DNLOAD_RESPONSE_STR, 16);

	public static final String XLJZ_FMS_DNLOAD_STR = "90042601";
	public static final long XLJZ_FMS_DNLOAD = Long.parseLong(XLJZ_FMS_DNLOAD_STR, 16);
	
	public static final String XLJZ_FMS_DNLOAD_RESPONSE_STR = "80042601";
	public static final long XLJZ_FMS_DNLOAD_RESPONSE = Long.parseLong(XLJZ_FMS_DNLOAD_RESPONSE_STR, 16);
	
	
	//��������ϴ�
	//��������ϴ�
	public static final String LP_DATA_STR = "80084600";
	public static final long LP_DATA = Long.parseLong(LP_DATA_STR, 16);
	

	public static final String LP_HISTDATA_STR = "80084601";
	public static final long LP_HISTDATA = Long.parseLong(LP_HISTDATA_STR, 16);

	
	//������ݷ���
	public static final String LP_DATA_RESPONSE_STR = "90074600";
	public static final long LP_DATA_RESPONSE = Long.parseLong(LP_DATA_RESPONSE_STR, 16);
	
	public static final String LP_HISTDATA_RESPONSE_STR = "90074601";
	public static final long LP_HISTDATA_RESPONSE = Long.parseLong(LP_HISTDATA_RESPONSE_STR, 16);



	//����
	public static final String LP_006_CONTROL_STR = "90054600";
	public static final long LP_006_CONTROL = Long.parseLong(LP_006_CONTROL_STR, 16);

	//��������
	public static final String LP_006_RESPONSE_STR = "80054600";
	public static final long LP_006_RESPONSE = Long.parseLong(LP_006_RESPONSE_STR, 16);
	
	//�豸����״̬����
	public static final String LP_007_STR = "80084602";
	public static final long LP_007 = Long.parseLong(LP_007_STR, 16);
	
	//�豸����
	public static final String LP_008_STR = "80084603";
	public static final long LP_008 = Long.parseLong(LP_008_STR, 16);
	
	//δ�ϴ���ݲ�ѯ
	public static final String LP_009_QUERY_STR = "90044600";
	public static final long LP_009 = Long.parseLong(LP_009_QUERY_STR, 16);

	//δ�ϴ���ݲ�ѯ����
	public static final String LP_009_RESPONSE_STR = "80044600";
	public static final long LP_009_RESPONSE = Long.parseLong(LP_009_RESPONSE_STR, 16);
	
	//���±��Ϊδ�ϴ��ļ�¼
	public static final String LP_010_QUERY_STR = "90044601";
	public static final long LP_010_QUERY = Long.parseLong(LP_010_QUERY_STR, 16);

	//���±��Ϊδ�ϴ��ļ�¼����
	public static final String LP_010_RESPONSE_STR = "80044601";
	public static final long LP_010_RESPONSE = Long.parseLong(LP_010_RESPONSE_STR, 16);
	
	//������ݼ�����ѯ
	public static final String LP_STATE_QUERY_STR = "90044602";
	public static final long LP_STATE_QUERY = Long.parseLong(LP_STATE_QUERY_STR, 16);
	
	public static final String LP_STATE_FEEDBACK_STR = "80044602";
	public static final long LP_STATE_FEEDBACK = Long.parseLong(LP_STATE_FEEDBACK_STR, 16);
	
	public static final String LP_DEVSTATE_POLL_STR = "80014600";
	public static final long LP_DEVSTATE_POLL = Long.parseLong(LP_DEVSTATE_POLL_STR, 16);
	
	public static final String LP_UPLOADSTATE_POLL_STR = "80014601";
	public static final long LP_UPLOADSTATE_POLL = Long.parseLong(LP_UPLOADSTATE_POLL_STR, 16);

	public static final String LP_105_RESPONSE_STR = "80014602";
	public static final long LP_105_RESPONSE = Long.parseLong(LP_105_RESPONSE_STR, 16);
	
	//A5IB
	public static final String A5IB_UPLOADFILE_STR = "90052700";
	public static final long A5IB_UPLOADFILE = Long.parseLong(A5IB_UPLOADFILE_STR, 16);
	
	public static final String A5IB_UPLOADFILE_RSP_STR = "80052700";
	public static final long A5IB_UPLOADFILE_RSP = Long.parseLong(A5IB_UPLOADFILE_RSP_STR, 16);
	
	public static final String A5IB_POLLBRIGHTNESS_STR = "80012700";
	public static final long A5IB_POLLBRIGHTNESS = Long.parseLong(A5IB_POLLBRIGHTNESS_STR, 16);

	public static final String A5IB_SETBRIGHTNESS_STR = "90052701";
	public static final long A5IB_SETBRIGHTNESS = Long.parseLong(A5IB_SETBRIGHTNESS_STR, 16);

	public static final String A5IB_SETBRIGHTNESS_RSP_STR = "80052701";
	public static final long A5IB_SETBRIGHTNESS_RSP = Long.parseLong(A5IB_SETBRIGHTNESS_RSP_STR, 16);

	
	
	//A5VDT
	public static final String A5VDT_POLL_STR = "80011C00";
	public static final long A5VDT_POLL = Long.parseLong(A5VDT_POLL_STR, 16);

	//opus
	public static final String OPUS_POLL_STR = "80015200";
	public static final long OPUS_POLL = Long.parseLong(OPUS_POLL_STR, 16);	

	//FIXME:����������г�ͻ������
	//��ͨ��������Э��
	public static final String JTBRD_RT_POLL_STR = "80011D00";
	public static final long JTBRD_RT_POLL = Long.parseLong(JTBRD_RT_POLL_STR, 16);
	
	public static final String JTBRD_HISTDATA_POLL_STR = "80031D00";
	public static final long JTBRD_HISTDATA_POLL = Long.parseLong(JTBRD_HISTDATA_POLL_STR, 16);

	public static final String JTBRD_RESTORE_DATA_CMD_STR = "90031D00";
	public static final long JTBRD_RESTORE_DATA_CMD = Long.parseLong(JTBRD_RESTORE_DATA_CMD_STR, 16);
	
	public static final String RTMS_RT_POLL_STR = "80011E00";
	public static final long RTMS_RT_POLL= Long.parseLong(RTMS_RT_POLL_STR, 16);
	
	//�����豸Э��
	
	//��ʪ��
	public static final String TEMPHUMI_POLL_RT_STR = "8001A200";
	public static final long TEMPHUMI_POLL_RT = Long.parseLong(TEMPHUMI_POLL_RT_STR, 16);
	
	//©ˮ���
	public static final String TTSIM_POLL_RT_STR = "8001A300";
	public static final long TTSIM_POLL_RT = Long.parseLong(TTSIM_POLL_RT_STR, 16);
	
	//�յ���ѯ
	public static final String AIRCOND_POLL_RT_STR = "8001A400";
	public static final long AIRCOND_POLL_RT = Long.parseLong(AIRCOND_POLL_RT_STR, 16);
	
	//�յ�����
	public static final String AIRCOND_STATE_RT_STR = "8001A401";
	public static final long AIRCOND_STATE_RT = Long.parseLong(AIRCOND_STATE_RT_STR, 16);
	
	//UPS
	public static final String IMVUPS_POLL_RT_STR = "8001A500";
	public static final long IMVUPS_POLL_RT = Long.parseLong(IMVUPS_POLL_RT_STR, 16);
	
	//���ֱ���
	public static final String FIRECONTROL_POLL_RT_STR = "80016100";
	public static final long FIRECONTROL_POLL_RT = Long.parseLong(FIRECONTROL_POLL_RT_STR, 16);

	//WD
	public static final String MORI_WD_POLL_RT_STR = "80015300";
	public static final long MORI_WD_POLL_RT = Long.parseLong(MORI_WD_POLL_RT_STR, 16);
	
	//����վ
	public static final String MORI_VM_POLL_RT_STR = "80015400";
	public static final long MORI_VM_POLL_RT = Long.parseLong(MORI_VM_POLL_RT_STR, 16);

	//visic
	public static final String VISIC_VM_POLL_RT_STR = "80015500";
	public static final long VISIC_VM_POLL_RT = Long.parseLong(VISIC_VM_POLL_RT_STR, 16);
	
	//datamate3000
	public static final String DATAMATE3000_POLL_RT_STR =  "8001A600";
	public static final long DATAMATE3000_POLL_RT = Long.parseLong(DATAMATE3000_POLL_RT_STR, 16);
	public static final String DATAMATE3000_ALARM_RT_STR =  "8001A601";
	
	//hqyb
	public static final String HQYBPLC_POLL_STR = "8001A700";
	public static long HQYBPLC_POLL = Long.parseLong(HQYBPLC_POLL_STR,16);
	
	public static final String HQYB_XFTH_POLL_RT_STR= "8001A800";
	public static final long HQYB_XFTH_POLL_RT = Long.parseLong(HQYB_XFTH_POLL_RT_STR,16);

	public static final String HQYB_BC_POLL_RT_STR= "8001A900";
	public static final long HQYB_BC_POLL_RT = Long.parseLong(HQYB_BC_POLL_RT_STR,16);
	
	public static final String HQYB_BC_CMD_STR = "9005A900";
	public static final long HQYB_BC_CMD = Long.parseLong(HQYB_BC_CMD_STR, 16);
	
	public static final String HQYB_BC_RESPONSE_STR= "8005A900";
	public static final long HQYB_BC_RESPONSE = Long.parseLong(HQYB_BC_RESPONSE_STR,16);
	
	public static final String HQYB_FA_POLL_RT_STR= "8001AA00";
	public static final long HQYB_FA_POLL_RT = Long.parseLong(HQYB_FA_POLL_RT_STR,16);
	
	public static final String HQYB_EPS_STATE_RT_STR= "8001AB00";
	public static final long HQYB_EPS_STATE_RT = Long.parseLong(HQYB_EPS_STATE_RT_STR,16);
	
	public static final String HQYB_EPS_DATA_RT_STR= "8001AC00";
	public static final long HQYB_EPS_DATA_RT = Long.parseLong(HQYB_EPS_DATA_RT_STR,16);

	public static final String PMU_RT_DATA_STR ="8001B100";
	public static final long PMU_RT_DATA=Long.parseLong(PMU_RT_DATA_STR,16);
	
	public static final String IEC104_RT_DATA_STR ="8001C100";
	public static final long IEC104_RT_DATA=Long.parseLong(IEC104_RT_DATA_STR,16);
	
	public static final String SCADA_RT_DATA_STR ="8001C200";
	public static final long SCADA_RT_DATA=Long.parseLong(SCADA_RT_DATA_STR,16);
	
	public static final String ATS_STATUS_STR ="8001C300";
	public static final long ATS_STATUS=Long.parseLong(ATS_STATUS_STR,16);
	public static final String ATS_PLAN_STR ="8001C400";
	public static final long ATS_PLAN=Long.parseLong(ATS_PLAN_STR,16);
	
	public static final String ATS_BC_STR ="8001C500";
	public static final long ATS_BC=Long.parseLong(ATS_STATUS_STR,16);
	public static final String SBC_RT_STR ="8001C600";
	public static final long SBC_RT=Long.parseLong(SBC_RT_STR,16);
//��ʿЭ��
	public static final String BUS_RT_STR ="8001D100";
	public static final long BUS_RT=Long.parseLong(BUS_RT_STR,16);
	//��ʿЭ��
	public static final String PDBUS_RT_STR ="8001D101";
	public static final long PDBUS_RT=Long.parseLong(PDBUS_RT_STR,16);
//�������
	public static final String EM_RT_STR ="8001D200";
	public static final long EM_RT=Long.parseLong(EM_RT_STR,16);
//���˼��
	public static final String PD_RT_STR ="8001D300";
	public static final long PD_RT=Long.parseLong(PD_RT_STR,16);
//ռ���ʼ��
	public static final String PCT_RT_STR ="8001D400";
	public static final long PCT_RT=Long.parseLong(PCT_RT_STR,16);

/*���ѵ�Э��-------------------------------------------------------------------------------------------------*/	

	//�۲�΢��������Э��
	public static final String HC_MVDT_POLL_STR = "80011B00";
	public static final long HC_MVDT_POLL = Long.parseLong(HC_MVDT_POLL_STR, 16);
	
	public static final String HC_MVDT_HISTDATA_POLL_STR = "80011B01";
	public static final long HC_MVDT_HISTDATA_POLL = Long.parseLong(HC_MVDT_HISTDATA_POLL_STR, 16);



	
	//�ѿؾ���ͨ����Ϣ
	public static final String RC_ALOHA_INFO_STR = "80073000";
	public static final long RC_ALOHA_INFO = Long.parseLong(RC_ALOHA_INFO_STR, 16);
	//�յ������·�
	public static final String RC_CMD_CONTROL_STR = "90053001";
	public static final long RC_CMD_CONTROL = Long.parseLong(RC_CMD_CONTROL_STR,16);
	public static final String RC_CMD_TEXT_STR = "90053000";
	public static final long RC_CMD_TEXT = Long.parseLong(RC_CMD_TEXT_STR, 16);
	public static final String IB_CMD_TEXT_STR = "90052000";
	public static final long IB_CMD_TEXT = Long.parseLong(IB_CMD_TEXT_STR, 16);
	public static final String IB_CMD_LB_STR = "90052001";
	public static final long IB_CMD_LB = Long.parseLong(IB_CMD_LB_STR, 16);
	public static final String IB_CMD_STATIC_STR = "90052002";
	public static final long IB_CMD_STATIC = Long.parseLong(IB_CMD_STATIC_STR, 16);
	public static final String IB_CMD_SWITCH_STR = "90052003";
	public static final long IB_CMD_SWITCH = Long.parseLong(IB_CMD_SWITCH_STR, 16);
	public static final String IB_CMD_ARROW_STR = "90052004";
	public static final long IB_CMD_ARROW = Long.parseLong(IB_CMD_ARROW_STR, 16);
	public static final String IB_ARROW_SWITCH_STR = "90052005";
	public static final long IB_ARROW_SWITCH = Long.parseLong(IB_ARROW_SWITCH_STR, 16);
	
	//�յ������·�(exprc)
	public static final String EXPRC_CMD_CONTROL_STR = "90053300";
	public static final long EXPRC_CMD_CONTROL = Long.parseLong(EXPRC_CMD_CONTROL_STR,16);
	
	public static final String EXPRC_CMD_TEXT_STR = "90053301";
	public static final long EXPRC_CMD_TEXT = Long.parseLong(EXPRC_CMD_TEXT_STR, 16);
	
	public static final String EXPRC_IB_CMD_TEXT_STR = "90053302";
	public static final long EXPRC_IB_CMD_TEXT = Long.parseLong(EXPRC_IB_CMD_TEXT_STR, 16);

	public static final String EXPRC_IB_CMD_LB_STR = "90053303";
	public static final long EXPRC_IB_CMD_LB = Long.parseLong(EXPRC_IB_CMD_LB_STR, 16);
	
	public static final String EXPRC_IB_CMD_STATIC_STR = "90053304";
	public static final long EXPRC_IB_CMD_STATIC = Long.parseLong(EXPRC_IB_CMD_STATIC_STR, 16);
	
	public static final String EXPRC_TRAFFICSIGNAL_CMD_STR = "9005300A";
	public static final long EXPRC_TRAFFICSIGNAL_CMD = Long.parseLong(EXPRC_TRAFFICSIGNAL_CMD_STR, 16);
	
	
	//�յ������·�����(exprc)
	
	public static final String EXPRC_CMD_CONTROL_RESPONSE_STR = "80053300";
	public static final long EXPRC_CMD_CONTROL_RESPONSE = Long.parseLong(EXPRC_CMD_CONTROL_RESPONSE_STR,16);
	
	public static final String EXPRC_CMD_TEXT_RESPONSE_STR = "80053301";
	public static final long EXPRC_CMD_TEXT_RESPONSE = Long.parseLong(EXPRC_CMD_TEXT_RESPONSE_STR, 16);
	
	public static final String EXPRC_IB_CMD_TEXT_RESPONSE_STR = "80053302";
	public static final long EXPRC_IB_CMD_TEXT_RESPONSE = Long.parseLong(EXPRC_IB_CMD_TEXT_RESPONSE_STR, 16);

	public static final String EXPRC_IB_CMD_LB_RESPONSE_STR = "80053303";
	public static final long EXPRC_IB_CMD_LB_RESPONSE = Long.parseLong(EXPRC_IB_CMD_LB_RESPONSE_STR, 16);
	
	public static final String EXPRC_IB_CMD_STATIC_RESPONSE_STR = "80053304";
	public static final long EXPRC_IB_CMD_STATIC_RESPONSE = Long.parseLong(EXPRC_IB_CMD_STATIC_RESPONSE_STR, 16);
	
	public static final String EXPRC_TRAFFICSIGNAL_CMD_RESPONSE_STR = "8005300A";
	public static final long EXPRC_TRAFFICSIGNAL_CMD_RESPONSE = Long.parseLong(EXPRC_TRAFFICSIGNAL_CMD_RESPONSE_STR, 16);



	
	
	
	//���յ�
	public static final String AIRLIGHTCONTROLLER_CMD_STR = "90054A00";
	public static final long AIRLIGHTCONTROLLER_CMD = Long.parseLong(AIRLIGHTCONTROLLER_CMD_STR, 16);
	//��ʪ��
	public static final String MUNTERSDHAREA_CMD_STR = "90054500";
	public static final long MUNTERSDHAREA_CMD = Long.parseLong(MUNTERSDHAREA_CMD_STR, 16);
	//���
	public static final String FOGLIGHT_CMD_STR = "90059A00";
	public static final long FORLIGHT_CMD = Long.parseLong(FOGLIGHT_CMD_STR, 16);
	//��ɽPLC���������·�
	public static final String ZS_PLC_CMD_STR = "90059E00";
	public static final long ZS_PLC_CMD = Long.parseLong(ZS_PLC_CMD_STR, 16);
	
	//HQYBPLC
	
	public static final String HQYB_PLC_CMD_STR = "9005A700";
	public static final long HQYB_PLC_CMD = Long.parseLong(HQYB_PLC_CMD_STR, 16);
	
    //pmuset
	
	public static final String PMU_SET_CMD_STR = "9005B100";
	public static final long PMU_SET_CMD = Long.parseLong(PMU_SET_CMD_STR, 16);
	
	
	public static final String SB_CMD_TEXT_STR = "90052400";
	public static final long SB_CMD_TEXT = Long.parseLong(SB_CMD_TEXT_STR, 16);
	//��ʷ��ݻָ��·�
	public static final String VDT_RESTORE_DATA_CMD_STR = "90031000";
	public static final long VDT_RESTORE_DATA_CMD = Long.parseLong(VDT_RESTORE_DATA_CMD_STR, 16);
	public static final String RC_RESTORE_DATA_CMD_STR = "90033000";
	public static final long RC_RESTORE_DATA_CMD = Long.parseLong(RC_RESTORE_DATA_CMD_STR, 16);
	//��ʷ��ݻָ��ϴ�
	public static final String VDT_RESTORE_DATA_POLL_STR = "80031000";
	public static final long VDT_RESTORE_DATA_POLL = Long.parseLong(VDT_RESTORE_DATA_POLL_STR, 16);
	public static final String RC_RESTORE_DATA_POLL_STR = "80033000";
	public static final long RC_RESTORE_DATA_POLL = Long.parseLong(RC_RESTORE_DATA_POLL_STR, 16);
	
	//���������ʷ��ݻָ�ָ���·�
	public static final String SEARIYFCP_RESTORE_WHOLE_CMD_STR = "90034300";
	public static final long SEARIYFCP_RESTORE_WHOLE_CMD = Long.parseLong(SEARIYFCP_RESTORE_WHOLE_CMD_STR, 16);
	public static final String SEARIYFCP_RESTORE_DATA_CMD_STR = "90034301";
	public static final long SEARIYFCP_RESTORE_DATA_CMD = Long.parseLong(SEARIYFCP_RESTORE_DATA_CMD_STR, 16);
	
	//���������ʷ����ϴ�
	public static final String SEARIYFCP_RESTORE_WHOLE_POLL_STR = "80034300";
	public static final long SEARIYFCP_RESTORE_WHOLE_POLL = Long.parseLong(SEARIYFCP_RESTORE_WHOLE_POLL_STR, 16);
	public static final String SEARIYFCP_RESTORE_DATA_POLL_STR = "80034301";
	public static final long SEARIYFCP_RESTORE_DATA_POLL = Long.parseLong(SEARIYFCP_RESTORE_DATA_POLL_STR, 16);

	
	//�յ������ִ	
	public static final String IB_RESPONSE_TEXT_STR = "80052000";
	public static final long IB_RESPONSE_TEXT = Long.parseLong(IB_RESPONSE_TEXT_STR, 16);
	public static final String IB_REPONSE_LB_STR = "80052001";
	public static final long IB_RESPONSE_LB = Long.parseLong(IB_REPONSE_LB_STR, 16);
	public static final String IB_RESPONSE_STATIC_STR = "80052002";
	public static final long IB_RESPONSE_STATIC = Long.parseLong(IB_RESPONSE_STATIC_STR, 16);
	public static final String IB_RESPONSE_SWITCH_STR = "80052003";
	public static final long IB_RESPONSE_SWITCH = Long.parseLong(IB_RESPONSE_SWITCH_STR, 16);
	public static final String IB_RESPONSE_ARROW_STR = "80052004";
	public static final long IB_RESPONSE_ARROW = Long.parseLong(IB_RESPONSE_ARROW_STR, 16);
	public static final String IB_RESPONSE_ARROW_SWITCH_STR = "80052005";
	public static final long IB_RESPONSE_ARROW_SWITCH = Long.parseLong(IB_RESPONSE_ARROW_SWITCH_STR, 16);
	public static final String RC_REPONSE_RB_STR = "80053000";
	public static final long RC_RESPONSE_RB = Long.parseLong(RC_REPONSE_RB_STR, 16);
	public static final String RC_REPONSE_PL_STR = "80053001";
	public static final long RC_RESPONSE_PL = Long.parseLong(RC_REPONSE_PL_STR, 16);
	public static final String SB_RESPONSE_TEXT_STR = "80052400";
	public static final long SB_RESPONSE_TEXT = Long.parseLong(SB_RESPONSE_TEXT_STR, 16);
	public static final String IB_CHARUNIT_SELFCHECK_RESPONSE_STR = "80022007";
	public static final long IB_CHARUNIT_SELFCHECK_RESPONSE = Long.parseLong(IB_CHARUNIT_SELFCHECK_RESPONSE_STR, 16);
	public static final String IB_CHARUNIT_GET_CHECK_RESPONSE_STR = "80022008";
	public static final long IB_CHARUNIT_GET_CHECK_RESPONSE = Long.parseLong(IB_CHARUNIT_GET_CHECK_RESPONSE_STR, 16);
	//���ձ��������·���ִ
	public static final String AIRLIGHTCONTROLLER_RESPONSE_STR = "80054A00";
	public static final long AIRLIGHTCONTROLLER_RESPONSE = Long.parseLong(AIRLIGHTCONTROLLER_RESPONSE_STR, 16);
	//��ʪ�������·���ִ
	public static final String MUNTERSDHAREA_RESPONSE_STR = "80054500";
	public static final long MUNTERSDHAREA_RESPONSE = Long.parseLong(MUNTERSDHAREA_RESPONSE_STR, 16);
	//��������·���ִ
	public static final String FOGLIGHT_RESPONSE_STR = "80059A00";
	public static final long FOGLIGHT_RESPONSE = Long.parseLong(FOGLIGHT_RESPONSE_STR, 16);
	//��ɽPLC�·������ִ
	public static final String ZS_PLC_RESPONSE_STR = "80059E00";
	public static final long ZS_PLC_RESPONSE = Long.parseLong(ZS_PLC_RESPONSE_STR, 16);
	//hqyb
	public static final String HQYBPLC_PLC_RESPONSE_STR= "8005A700";
	public static final long HQYBPLC_PLC_RESPONSE = Long.parseLong(HQYBPLC_PLC_RESPONSE_STR,16);
	//����������ʵʱ����ϴ�
	public static final String LC_POLL_STR = "80013A00";
	public static long LC_POLL = Long.parseLong(LC_POLL_STR, 16);
	
	//�����������·�
	public static final String LC_CONTROL_STR = "90053A00";
	public static long LC_CONTROL = Long.parseLong(LC_CONTROL_STR, 16);
	
	//�����������·�����
	public static final String LC_CONTROL_RESPONSE_STR = "80053A00";
	public static long LC_CONTROL_RESPONSE = Long.parseLong(LC_CONTROL_RESPONSE_STR, 16);
	
	//����ģ�����㲥����
	public static final String TMMNP_BROADCAST_CONTROL_STR = "90059F00";
	public static long TMMNP_BROADCAST_CONTROL = Long.parseLong(TMMNP_BROADCAST_CONTROL_STR, 16);
	
	//����ģ����ң������
	public static final String TMMNP_YC_CONTROL_STR = "90059F01";
	public static long TMMNP_YC_CONTROL = Long.parseLong(TMMNP_YC_CONTROL_STR, 16);

	//����ģ����ң������
	public static final String TMMNP_YX_CONTROL_STR = "90059F02";
	public static long TMMNP_YX_CONTROL = Long.parseLong(TMMNP_YX_CONTROL_STR, 16);
	
	//����ģ�����㲥��������
	public static final String TMMNP_BROADCAST_FEEDBACK_STR = "80059F00";
	public static long TMMNP_BROADCAST_FEEDBACK = Long.parseLong(TMMNP_BROADCAST_FEEDBACK_STR, 16);
	
	//����ģ����ң�ⷴ������
	public static final String TMMNP_YC_FEEDBACK_STR = "80059F01";
	public static long TMMNP_YC_FEEDBACK = Long.parseLong(TMMNP_YC_FEEDBACK_STR, 16);

	//����ģ����ң�ŷ�������
	public static final String TMMNP_YX_FEEDBACK_STR = "80059F02";
	public static long TMMNP_YX_FEEDBACK = Long.parseLong(TMMNP_YX_FEEDBACK_STR, 16);


	public static final String LTM8000_POLL_STR = "8001A000";
	public static final long LTM8000_POLL = Long.parseLong(LTM8000_POLL_STR, 16);
	
	public static final String JEIDAR_UPS_POLL_STR = "8001A100";
	public static final long JEIDAR_UPS_POLL = Long.parseLong(JEIDAR_UPS_POLL_STR, 16);

	
	
	
	//ͨ���¼�
	public static final String COMM_EVENT_STR = "80010000";
	public static final long COMM_EVENT = Long.parseLong(COMM_EVENT_STR, 16);
	//ͨ��MODBUS
	public static final String DEV_MODBUS_QUERY_CMD_STR = "90000000";
	public static final long DEV_MODBUS_QUERY_CMD = Long.parseLong(DEV_MODBUS_QUERY_CMD_STR, 16);
	public static final String DEV_MODBUS_NORMAL_ECHO_STR = "80000000";
	public static final long DEV_MODBUS_NORMAL_ECHO = Long.parseLong(DEV_MODBUS_NORMAL_ECHO_STR, 16);
	public static final String DEV_MODBUS_ERROR_ECHO_STR = "80000001";
	public static final long DEV_MODBUS_ERROR_ECHO = Long.parseLong(DEV_MODBUS_ERROR_ECHO_STR, 16);
	public static final String IB_CHAR_SELF_CHECK_WRITE = "90022007";
	public static final String IB_CHAR_GET_SELF_CHECK = "90022008";
	//������
    public static final String SPE_HEART_TEST_STR ="FFFFFFFF";
    public static final long SPE_HEART_TEST = Long.parseLong(SPE_HEART_TEST_STR,16);
    public static final String SPE_HEART_TEST_ECHO_STR ="FFFFFFFF";
    public static final long SPE_HEART_TEST_ECHO = Long.parseLong(SPE_HEART_TEST_ECHO_STR,16);
    
    /**
     * Initialize FcCommand according to func code.
     * @author pdv
     *
     */
	interface FcCommandInitializer {
		public void init(FcCommand cmd);
		public void decode(FcCommand command, ProcessThread thd) throws Exception;
	}
	
	//��ѯ����
	private abstract static class PollCmdInitializer implements FcCommandInitializer {
		public void init(FcCommand cmd) {
			cmd.setID();
			cmd.setTimeID();
			cmd.setRtPollPriority();
		}
	}
	
	private abstract static class HighPriorityPollCmdInitializer implements FcCommandInitializer {
		public void init(FcCommand cmd) {
			cmd.setID();
			cmd.setTimeID();
			cmd.setHighPriority();
		}
	}
	
	//��ʷ����
	private abstract static class HistCmdInitializer implements FcCommandInitializer {
		public void init(FcCommand cmd) {
			cmd.setID();
			cmd.setTimeID();
			cmd.setHistPollPriority();
		}
	}
		
	//����ͷ���
	private  abstract static class RtCmdResponseInitializer implements FcCommandInitializer {
		public void init(FcCommand cmd) {
			cmd.setID();
			cmd.setUID();
			cmd.setRtCmdPriority();
		}
	}
	
	private  abstract static class RtCmdRequestInitializer implements FcCommandInitializer {
		public void init(FcCommand cmd) {
			cmd.setID();
			cmd.setUID();
			cmd.setRtCmdPriority();
		}
	}
		
	private static final Map<Long, FcCommandInitializer> initializerMap
		= new HashMap<Long, FcCommandInitializer>();
	
	static {
		
//		initializerMap.put(HQYB_EPS_DATA_RT, new PollCmdInitializer() {
//
//			public void decode(FcCommand command, ProcessThread thd) throws Exception {
//				HQYBEPSProtocol.INSTANCE.processData(command, thd);
//			}
//		});

		//---------------------------------------------------------------
		//������Э��
		initializerMap.put(SPE_HEART_TEST, new FcCommandInitializer() {

			public void init(FcCommand cmd) {
				cmd.setRtCmdPriority();
			}

			public void decode(FcCommand command, ProcessThread thd) throws Exception {
				thd.sendToComm(FrameGenerator.genFrame(command.rawstr));				
			}
		});
	}
    
	/**
     * @param ver
     * @param funcCode
	 * @throws FcCommandException
	 * �������Ž��г�ʼ������
     */
    private void initCommand(long funcCode) throws FcCommandException {
    	FcCommandInitializer cmdInit = initializerMap.get(funcCode);
    	if (cmdInit == null) {
    		throw new FcCommandException("unsupported func code:"+Long.toHexString(funcCode));
    	} else {
    		cmdInit.init(this);
    	}
	}
    
    private static final Logger logger = Logger.getLogger(FcCommand.class);
    
    public void decode(ProcessThread thd) throws SQLException {
    	long funcCode = this.getIFuncCode();
    	FcCommandInitializer cmdInit = initializerMap.get(funcCode);
    	if (cmdInit == null) {
    		logger.error("unsupported func code:"+Long.toHexString(funcCode));
    	} else {
    		try {
				cmdInit.decode(this, thd);
			} catch (RegTblParserException e) {
	    		logger.error("data segment error", e);
	        
	        } catch (CommandException e) {
	            logger.error("fc command error", e);
	        } catch(SQLException e) {
	        	throw e;
	        } catch (NullPointerException e){
	        	throw e;
	        }
	        catch (Exception e) {
	        	throw new RuntimeException(e);
	        }
    	}
    }
	
	
    /**
	 * �ź�������:0-up comm->proc 1-down proc->comm
	 */
	public boolean isDown() throws FcCommandException {
	    return this.isDown;
	}
    /**
     * @return Returns the data.
     */
    public String getData() {
        return data;
    }
    public long getIFuncCode() {
        return iFuncCode;
    }
    /**
     * @return Returns the id.
     * @throws FcCommandException
     */
    public String getId() throws FcCommandException {
        if (!this.hasID)
            throw new FcCommandException(this+" doesn't has ID");
        return id;
    }
    /**
     * @return Returns the versionNo.
     */
    public int getVersionNo() {
        return versionNo;
    }
    
    /**
     * @return Returns the iSubCode.
     * @throws FcCommandException
     */
    public int getISubCode() throws FcCommandException {
        if (!this.hasSubCode)
            throw new FcCommandException(this+" doesn't has sub code");
        return iSubCode;
    }
    /**
     * @return Returns the timeID.
     * @throws FcCommandException
     */
    public String getTimeID() throws FcCommandException {
        if (!this.hasTimeID)
            throw new FcCommandException(this+" doesn't has TimeID");
        return timeID;
    }
    public Date getTime() throws FcCommandException {
        if (!this.hasTimeID)
            throw new FcCommandException(this+" doesn't has TimeID");
        return time;
    }
    /**
     * @return Returns the uID.
     * @throws FcCommandException
     */
    public String getUID() throws FcCommandException {
        if (!this.hasUID)
            throw new FcCommandException(this+" doesn't has UID");
        return uID;
    }
    public String toString() {
        return "fc:"+this.sFuncCode+
        	(this.hasID ? " id:"+this.id : "")+
        	(this.hasTimeID ? " timeid:"+this.timeID : "")+
        	(this.hasSubCode ? " subcode:"+this.sSubCode : "")+
        	(this.hasUID ? " uid:"+this.uID : "")+
        	" data:"+this.data;
    }
    /**
     * return command id
     */
    public String getCommandID() {
        return this.sFuncCode;
    }
    
    public void setSubData(int startwordlen){
    	this.data = this.data.substring(startwordlen * WORDLEN);
    }
    
    private final int WORDLEN = 4;
    
    public static void main(String[] args) {
		try {
			FcCommand cmd = new FcCommand("aa");
		} catch (FcCommandException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
